﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO.IsolatedStorage;

namespace DSA.List_Menu
{
    public partial class MainSettingsPage : PhoneApplicationPage
    {
        public MainSettingsPage()
        {
            InitializeComponent();
        }

        private void btnClearData_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to delete all content?", "Warning", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    if (myIsolatedStorage.FileExists("shopping_lists.xml"))
                    {
                        myIsolatedStorage.DeleteFile("shopping_lists.xml");
                    }

                    int i = 0;
                    while (myIsolatedStorage.FileExists("shopping_lists" + i + ".xml"))
                    {
                        myIsolatedStorage.DeleteFile("shopping_lists" + i + ".xml");
                        i++;
                    }

                    if (myIsolatedStorage.FileExists("main_lists.xml"))
                    {
                        myIsolatedStorage.DeleteFile("main_lists.xml");
                    }
                }
            }
        }
    }
}